package com.neusoft.resturant.controller;


import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResBanner;
import com.neusoft.resturant.service.IResBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.neusoft.resturant.common.utils.R.success;
import static com.neusoft.resturant.common.utils.R.toAjax;

/**
 * 轮播图Controller
 * 
 * @author Daniel
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/api/banner")
public class ResBannerController
{
    @Autowired
    private IResBannerService resBannerService;

    /**
     * 查询轮播图列表
     */
    @GetMapping("/list")
    public R list(ResBanner resBanner)
    {
        List<ResBanner> list = resBannerService.selectResBannerList(resBanner);
        return R.success(list);
    }
    /**
     * 获取轮播图详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {

        return R.success(resBannerService.selectResBannerById(id));
    }

    /**
     * 新增轮播图
     */
    @PostMapping()
    public R add(@RequestBody ResBanner resBanner)
    {
        return R.toAjax(resBannerService.insertResBanner(resBanner));
    }

    /**
     * 修改轮播图
     */
    @PutMapping
    public R edit(@RequestBody ResBanner resBanner)
    {
        return R.toAjax(resBannerService.updateResBanner(resBanner));
    }

    /**
     * 删除轮播图
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {

        return R.toAjax(resBannerService.deleteResBannerByIds(ids));
    }
}
